package ${content.controller.classPackage};

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import ${content.service.classPackage}.${content.service.className};
import ${content.entity.classPackage}.${content.entity.className};

/**
 * ${content.entity.className}的控制层接口服务
 * 
 * @author 
 *
 */
@Controller
public class ${content.controller.className} {

	/** ${content.entity.className}Service服务 */
	@Autowired
	private ${content.service.className} ${content.service.className?uncap_first};
	
	/**
	 * ${content.controller.item.f_find.describe!}
	 * @param value
	 * @return
	 */
	@RequestMapping(value = "${content.controller.item.r_find.value}", method = RequestMethod.POST)
	@ResponseBody
	public List<${content.entity.className}> ${content.controller.item.f_find.value}(${content.entity.className} value) {
		
		List<${content.entity.className}> list = ${content.service.className?uncap_first}.${content.service.item.selectListByObj.value}(value);
		
		return list;
		
	}
	
	<#if content.entity.primaryKeyAttr??>
	/**
	 * ${content.controller.item.f_getById.describe!}
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "${content.controller.item.r_getById.value}", method = RequestMethod.GET)
	@ResponseBody
	public ${content.entity.className} ${content.controller.item.f_getById.value}(@PathVariable(name="id") ${content.entity.primaryKeyAttr.javaType} id) {
		
		${content.entity.className} ${content.entity.className?uncap_first} = ${content.service.className?uncap_first}.${content.service.item.selectById.value!}(id);
		
		return ${content.entity.className?uncap_first};
	}
	</#if>
	
	/**
	 * ${content.controller.item.f_saveNotNull.describe!}
	 * @return
	 */
	@RequestMapping(value = "${content.controller.item.r_saveNotNull.value!}", method = RequestMethod.POST)
	public void ${content.controller.item.f_saveNotNull.value!}(${content.entity.className} value) {
		
		int code = ${content.service.className?uncap_first}.${content.service.item.insertNotNull.value!}(value);
		
	}
	
	/**
	 * ${content.controller.item.f_updateNotNull.describe!}
	 * @return
	 */
	@RequestMapping(value = "${content.controller.item.r_updateNotNull.value!}", method = RequestMethod.POST)
	public void ${content.controller.item.f_updateNotNull.value!}(${content.entity.className} value) {
	
		int code = ${content.service.className?uncap_first}.${content.service.item.updateNotNullById.value!}(value);
		
	}
	
	<#if content.entity.primaryKeyAttr??>
	/**
	 * ${content.controller.item.f_deleteById.describe!}
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "${content.controller.item.r_deleteById.value!}", method = RequestMethod.POST)
	public void ${content.controller.item.f_deleteById.value!}(@PathVariable(name="id") ${content.entity.primaryKeyAttr.javaType} id) {
	
		int code = ${content.service.className?uncap_first}.${content.service.item.deleteById.value!}(id);
		
	}
	</#if>
}
